<?php
class Shop_Form_Promotion_Add extends Promotor_Form_Scaffold {
	public function init() {
		$this->setMethod('post');
		$this->setAttrib('enctype', Zend_Form::ENCTYPE_MULTIPART);

		$this->addPrefixPath('Promotor_Form_Decorator_','Promotor/Form/Decorator', self::DECORATOR);
        
		$subForm = $this->_getContentForm();
        $this->addSubForm($subForm, 'promotion');
	}
	

	/**
     * @return Zend_Dojo_Form_SubForm
     */
    protected function _getContentForm() {
    	$subForm = new Zend_Form_SubForm();
        $subForm->setAttribs(array(
            'name'   => 'promotion',
            'legend' => 'Dane podstawowe',
        ));
        $subForm
            ->addElement(new KontorX_Form_Element_Db_Select('product_id', array(
            	'label' => 'Produkt',
                'description' => 'Wybierz produkt z listy',
            	'required' => true,
            	'tableName' => 'shop_product',
            	'tableCols' => array('key' => 'id','value' => 'name')
            )))

            // Okres promocji
            
            ->addElement(
                'text',
                't_start',
                array(
                    'label' => 'Data rozpoczęcia promocji',
                    'required'  => true,
                	'value' => date('Y-m-d'),
                	'attribs' => array(
                		'class' => 'datapicker'
                	),
                	'validators' => array(
                		'date' => array(
                			'validator' => 'Date', 
                			'options' => array('format'=>'Y-m-d'))
                	)
                )
            )
            ->addElement(
                'text',
                't_end',
                array(
                    'label' => 'Data końca promocji',
                    'required'  => true,
                	'attribs' => array(
                		'class' => 'datapicker'
                	),
                	'validators' => array(
                		'date' => array(
                			'validator' => 'Date', 
                			'options' => array('format'=>'Y-m-d'))
                	)
                )
            )

            // modyfikator

            ->addElement(
                'text',
                'value',
                array(
                    'label' => 'Wartość',
                    'required'  => true,
                	'description' => 'Dla wartości np. 5 i modyfikatora "%" - cena promocyjna to np.: 5%, dla modyfikatora "-"  - cena promocyjna to cena produktu pomniejszona o 5',
                	'validators' => array(
                		'float' => 'Float'
                	)
                )
            )
            ->addElement(
                'select',
                'modifer',
                array(
                    'label' => 'Modyfikator cenowy',
                	'description' => 'Sposób zmiany ceny produktu promocyjnego',
                    'required'  => true,
                	'multiOptions' => array(
                		'%' => '%',
		                '+' => '+',
		                '-' => '-'
                	)
                )
            );

        return $subForm;
    }
}